|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectcontrolP5.Controller
controlP5.Slider
public class Slider
a slider is either used horizontally or vertically. when adding a slider to controlP5, the width is compared versus the height. width is bigger, you get a horizontal slider, height is bigger, you get a vertical slider. a slider can have a fixed slide controller (one end of the slider is fixed to the left or bottom side of the controller), or a flexible slide control (a knob that you can drag).
/**
* ControlP5 Slider. Horizontal and vertical sliders,
* with and without tick marks and snap-to-tick.
* by andreas schlegel, 2010
*/
import controlP5.*;
ControlP5 controlP5;
int myColor = color(0,0,0);
int sliderValue = 100;
int sliderTicks1 = 100;
int sliderTicks2 = 30;
void setup() {
size(400,400);
controlP5 = new ControlP5(this);
// add a vertical slider
controlP5.addSlider("slider",0,200,128,20,100,10,100);
// create another slider with tick marks, now without
// default value, the initial value will be set according th
// the value of variable sliderTicks2 then.
controlP5.addSlider("sliderTicks1",0,255,100,100,10,100);
Slider s1 = (Slider)controlP5.controller("sliderTicks1");
s1.setNumberOfTickMarks(5);
// add horizontal sliders
controlP5.addSlider("sliderValue",0,255,128,200,180,100,10);
controlP5.addSlider("sliderTicks2",0,255,128,200,220,100,10);
Slider s2 = (Slider)controlP5.controller("sliderTicks2");
s2.setNumberOfTickMarks(7);
// use Slider.FIX or Slider.FLEXIBLE to change the slider handle
// by default it is Slider.FIX
s2.setSliderMode(Slider.FLEXIBLE);
}
void draw() {
background(sliderTicks1);
fill(sliderValue);
rect(0,0,width,100);
fill(myColor);
rect(0,300,width,70);
fill(sliderTicks2);
rect(0,370,width,30);
}
void slider(float theColor) {
myColor = color(theColor);
println("a slider event. setting background to "+theColor);
}
| Field Summary | |
|---|---|
static int |
FIX
|
static int |
FLEXIBLE
|
int |
valueLabelPositioning
|
| Fields inherited from interface controlP5.ControlP5Constants |
|---|
acceptClassList, ACTIVE, ALT, ARC, ARRAY, BACKSPACE, BOOLEAN, BOTTOM, CENTER, CONTROL, controlEventClass, CUSTOM, DECREASE, DEFAULT, DELETE, DOWN, ELLIPSE, ENTER, ESCAPE, EVENT, eventMethod, FIELD, FLOAT, HALF_PI, HIDE, HIGHLIGHT, HORIZONTAL, IMAGE, INCREASE, INTEGER, INVALID, KEYCONTROL, LEFT, LINE, LOAD, MENU, METHOD, MOVE, OVER, PI, PRESSED, PRINT, RELEASE, RESET, RIGHT, SAVE, SHIFT, SPRITE, STRING, SWITCH, SWITCH_BACK, SWITCH_FORE, TAB, TOP, TWO_PI, UP, VERBOSE, VERTICAL |
| Constructor Summary | |
|---|---|
Slider(ControlP5 theControlP5,
ControllerGroup theParent,
java.lang.String theName,
float theMin,
float theMax,
float theDefaultValue,
int theX,
int theY,
int theWidth,
int theHeight)
|
|
| Method Summary | |
|---|---|
void |
addToXMLElement(ControlP5XMLElement theElement)
|
void |
alignValueLabel(int theValue)
use static variables ControlP5.TOP, ControlP5.CENTER, ControlP5.BOTTOM to align the ValueLabel of a slider. |
int |
getNumberOfTickMarks()
|
TickMark |
getTickMark(int theIndex)
|
java.util.ArrayList<TickMark> |
getTickMarks()
|
Controller |
linebreak()
|
void |
onEnter()
|
void |
onLeave()
|
Controller |
setHeight(int theValue)
set the height of the slider. |
void |
setMax(float theValue)
set the maximum value of the slider. |
void |
setMin(float theValue)
set the minimum value of the slider. |
void |
setNumberOfTickMarks(int theNumber)
|
void |
setSliderMode(int theMode)
use the slider mode to set the mode of the slider bar, which can be Slider.FLEXIBLE or Slider.FIX |
void |
setValue(float theValue)
set the value of the slider. |
Controller |
setWidth(int theValue)
set the width of the slider. |
void |
showTickMarks(boolean theFlag)
|
void |
snapToTickMarks(boolean theFlag)
|
void |
update()
updates the value of the controller without having to set the value explicitly. |
void |
updateDisplayMode(int theMode)
|
void |
updateInternalEvents(processing.core.PApplet theApplet)
TODO |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int FIX
public static final int FLEXIBLE
public int valueLabelPositioning
| Constructor Detail |
|---|
public Slider(ControlP5 theControlP5,
ControllerGroup theParent,
java.lang.String theName,
float theMin,
float theMax,
float theDefaultValue,
int theX,
int theY,
int theWidth,
int theHeight)
theControlP5 - ControlP5theParent - ControllerGrouptheName - StringtheMin - floattheMax - floattheDefaultValue - floattheX - inttheY - inttheWidth - inttheHeight - int
/**
* ControlP5 Slider. Horizontal and vertical sliders,
* with and without tick marks and snap-to-tick.
* by andreas schlegel, 2010
*/
import controlP5.*;
ControlP5 controlP5;
int myColor = color(0,0,0);
int sliderValue = 100;
int sliderTicks1 = 100;
int sliderTicks2 = 30;
void setup() {
size(400,400);
controlP5 = new ControlP5(this);
// add a vertical slider
controlP5.addSlider("slider",0,200,128,20,100,10,100);
// create another slider with tick marks, now without
// default value, the initial value will be set according th
// the value of variable sliderTicks2 then.
controlP5.addSlider("sliderTicks1",0,255,100,100,10,100);
Slider s1 = (Slider)controlP5.controller("sliderTicks1");
s1.setNumberOfTickMarks(5);
// add horizontal sliders
controlP5.addSlider("sliderValue",0,255,128,200,180,100,10);
controlP5.addSlider("sliderTicks2",0,255,128,200,220,100,10);
Slider s2 = (Slider)controlP5.controller("sliderTicks2");
s2.setNumberOfTickMarks(7);
// use Slider.FIX or Slider.FLEXIBLE to change the slider handle
// by default it is Slider.FIX
s2.setSliderMode(Slider.FLEXIBLE);
}
void draw() {
background(sliderTicks1);
fill(sliderValue);
rect(0,0,width,100);
fill(myColor);
rect(0,300,width,70);
fill(sliderTicks2);
rect(0,370,width,30);
}
void slider(float theColor) {
myColor = color(theColor);
println("a slider event. setting background to "+theColor);
}
| Method Detail |
|---|
public void setSliderMode(int theMode)
theMode - intpublic void updateInternalEvents(processing.core.PApplet theApplet)
Controller
updateInternalEvents in interface ControllerInterfaceupdateInternalEvents in class ControllerControllerInterface.updateInternalEventspublic void setValue(float theValue)
setValue in class ControllertheValue - floatpublic void update()
Controller
update in interface ControllerInterfaceupdate in class Controllerpublic void setMin(float theValue)
setMin in class ControllertheValue - floatpublic void setMax(float theValue)
setMax in class ControllertheValue - floatpublic Controller setWidth(int theValue)
setWidth in class ControllertheValue - intpublic Controller setHeight(int theValue)
setHeight in class ControllertheValue - intpublic void addToXMLElement(ControlP5XMLElement theElement)
theElement - ControlP5XMLElementpublic void onEnter()
public void onLeave()
public void setNumberOfTickMarks(int theNumber)
public int getNumberOfTickMarks()
public void showTickMarks(boolean theFlag)
public void snapToTickMarks(boolean theFlag)
public TickMark getTickMark(int theIndex)
public java.util.ArrayList<TickMark> getTickMarks()
public void alignValueLabel(int theValue)
theValue - public Controller linebreak()
linebreak in class Controllerpublic void updateDisplayMode(int theMode)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||